package model.dao.admin;

import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import model.interfaces.HibernateGenericDAO;
import model.interfaces.admin.AdminDAO;
import model.vos.admin.Admin;

public class HibernateAdminDAO extends HibernateGenericDAO<Admin> 
								 implements AdminDAO{
	
	public HibernateAdminDAO(Session session) {		
		super(session);		
	}

	@Override
	public String login(Admin admin, String login, String senha) {
		
		admin = (Admin) this.getSession()
				.createCriteria(Admin.class)
				.add(Restrictions.eq("login",login))
				.add(Restrictions.eq("senha",senha))
				.uniqueResult();
		
		if ( admin != null){
					return "sucesso";	
				}else{
					return "falha";	
				}
			
		
	}
	public Admin loginAdmin(Admin admin, String login, String senha) {
		
		admin = (Admin) this.getSession()
				.createCriteria(Admin.class)
				.add(Restrictions.eq("login",login))
				.add(Restrictions.eq("senha",senha))
				.uniqueResult();
		
		if ( admin != null){
					return admin;	
				}else{
					return null;	
				}
			
		
	}
}
